package com.example.demo.controller;

import com.example.demo.common.Result;
import com.example.demo.entity.ClassInfo;
import com.example.demo.mapper.ClassMapper;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author lai
 * @data 2021/11/17
 * @apiNote
 */
@RestController
@RequestMapping("/class")
public class ClassController {

    @Resource
    ClassMapper classMapper;

    /**
     * 获取所有班级信息
     *
     * */
    @GetMapping
    public Result<?> find(){
        // 获取了表中所有数据
        List<ClassInfo> items = classMapper.selectList(null);
        return Result.success(items);
    }

    /**
     * 根据班级id查找该班级信息
     *
     * classId: 要查找的班级id
     * */
    @GetMapping("/{classId}")
    public Result<?> findId(@PathVariable Integer classId){
        ClassInfo classinfo = classMapper.selectById(classId);
        return Result.success(classinfo);
    }


}
